<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- Copyright © 1988-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
"GNU Free Documentation License".

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<title>Tree overview (GNU Compiler Collection (GCC) Internals)</title>

<meta name="description" content="Tree overview (GNU Compiler Collection (GCC) Internals)">
<meta name="keywords" content="Tree overview (GNU Compiler Collection (GCC) Internals)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Option-Index.html" rel="index" title="Option Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="GENERIC.html" rel="up" title="GENERIC">
<link href="Types.html" rel="next" title="Types">
<link href="Deficiencies.html" rel="prev" title="Deficiencies">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
div.example {margin-left: 3.2em}
span:hover a.copiable-link {visibility: visible}
-->
</style>


</head>

<body lang="en">
<div class="section-level-extent" id="Tree-overview">
<div class="nav-panel">
<p>
Next: <a href="Types.html" accesskey="n" rel="next">Types</a>, Previous: <a href="Deficiencies.html" accesskey="p" rel="prev">Deficiencies</a>, Up: <a href="GENERIC.html" accesskey="u" rel="up">GENERIC</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h3 class="section" id="Overview-1"><span>11.2 Overview<a class="copiable-link" href="#Overview-1"> &para;</a></span></h3>
<a class="index-entry-id" id="index-tree"></a>
<a class="index-entry-id" id="index-TREE_005fCODE"></a>

<p>The central data structure used by the internal representation is the
<code class="code">tree</code>.  These nodes, while all of the C type <code class="code">tree</code>, are of
many varieties.  A <code class="code">tree</code> is a pointer type, but the object to
which it points may be of a variety of types.  From this point forward,
we will refer to trees in ordinary type, rather than in <code class="code">this
font</code>, except when talking about the actual C type <code class="code">tree</code>.
</p>
<p>You can tell what kind of node a particular tree is by using the
<code class="code">TREE_CODE</code> macro.  Many, many macros take trees as input and
return trees as output.  However, most macros require a certain kind of
tree node as input.  In other words, there is a type-system for trees,
but it is not reflected in the C type-system.
</p>
<p>For safety, it is useful to configure GCC with <samp class="option">--enable-checking</samp>.
Although this results in a significant performance penalty (since all
tree types are checked at run-time), and is therefore inappropriate in a
release version, it is extremely helpful during the development process.
</p>
<p>Many macros behave as predicates.  Many, although not all, of these
predicates end in &lsquo;<samp class="samp">_P</samp>&rsquo;.  Do not rely on the result type of these
macros being of any particular type.  You may, however, rely on the fact
that the type can be compared to <code class="code">0</code>, so that statements like
</p><div class="example smallexample">
<pre class="example-preformatted">if (TEST_P (t) &amp;&amp; !TEST_P (y))
  x = 1;
</pre></div>
<p>and
</p><div class="example smallexample">
<pre class="example-preformatted">int i = (TEST_P (t) != 0);
</pre></div>
<p>are legal.  Macros that return <code class="code">int</code> values now may be changed to
return <code class="code">tree</code> values, or other pointers in the future.  Even those
that continue to return <code class="code">int</code> may return multiple nonzero codes
where previously they returned only zero and one.  Therefore, you should
not write code like
</p><div class="example smallexample">
<pre class="example-preformatted">if (TEST_P (t) == 1)
</pre></div>
<p>as this code is not guaranteed to work correctly in the future.
</p>
<p>You should not take the address of values returned by the macros or
functions described here.  In particular, no guarantee is given that the
values are lvalues.
</p>
<p>In general, the names of macros are all in uppercase, while the names of
functions are entirely in lowercase.  There are rare exceptions to this
rule.  You should assume that any macro or function whose name is made
up entirely of uppercase letters may evaluate its arguments more than
once.  You may assume that a macro or function whose name is made up
entirely of lowercase letters will evaluate its arguments only once.
</p>
<p>The <code class="code">error_mark_node</code> is a special tree.  Its tree code is
<code class="code">ERROR_MARK</code>, but since there is only ever one node with that code,
the usual practice is to compare the tree against
<code class="code">error_mark_node</code>.  (This test is just a test for pointer
equality.)  If an error has occurred during front-end processing the
flag <code class="code">errorcount</code> will be set.  If the front end has encountered
code it cannot handle, it will issue a message to the user and set
<code class="code">sorrycount</code>.  When these flags are set, any macro or function
which normally returns a tree of a particular kind may instead return
the <code class="code">error_mark_node</code>.  Thus, if you intend to do any processing of
erroneous code, you must be prepared to deal with the
<code class="code">error_mark_node</code>.
</p>
<p>Occasionally, a particular tree slot (like an operand to an expression,
or a particular field in a declaration) will be referred to as
&ldquo;reserved for the back end&rdquo;.  These slots are used to store RTL when
the tree is converted to RTL for use by the GCC back end.  However, if
that process is not taking place (e.g., if the front end is being hooked
up to an intelligent editor), then those slots may be used by the
back end presently in use.
</p>
<p>If you encounter situations that do not match this documentation, such
as tree nodes of types not mentioned here, or macros documented to
return entities of a particular kind that instead return entities of
some different kind, you have found a bug, either in the front end or in
the documentation.  Please report these bugs as you would any other
bug.
</p>


<ul class="mini-toc">
<li><a href="Macros-and-Functions.html" accesskey="1">Trees</a></li>
<li><a href="Identifiers.html" accesskey="2">Identifiers</a></li>
<li><a href="Containers.html" accesskey="3">Containers</a></li>
</ul>
</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Types.html">Types</a>, Previous: <a href="Deficiencies.html">Deficiencies</a>, Up: <a href="GENERIC.html">GENERIC</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>
